/**************************************************************
  > File Name: 11.c
  > Author: LuoLiang
  > Mail: 1204553475@qq.com 
  > Created Time: 2022年01月25日 星期二 14时53分12秒
 **************************************************************/

#include <stdio.h>
#include <stdlib.h>

int maxArea(int* height, int heightSize)
{
	int *first = &height[0];
	int *last = &height[heightSize-1];
	int max = 0;
	int curVaule = 0;

	while (first != last)
	{
		if (*first < *last)
		{
			curVaule = (*first) * (last - first);
			first++;
		}
		else
		{
			curVaule = (*last) * (last - first);
			last--;
		}
		max = curVaule > max ? curVaule : max;
	}
	return max;
}

int main(int argc,char **argv)
{
	int n, ret;	
	int height[] = {4,3,2,1,4};
	
	n = sizeof(height) / sizeof(*height);
	ret = maxArea(height, n);
	printf("%d\n",ret);

    exit(0);
}
